﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BonsaiScrum.Core.Domain;

namespace BonsaiScrum.Core.Query
{
    public class UserReport
    {
        public virtual int Id { get; private set; }
        public virtual string FirstName { get; private set; }
        public virtual string LastName { get; private set; }
        public virtual string UserName { get; private set; }
        public virtual string Password { get; private set; }
        public virtual bool Active { get; private set; }
        public virtual PermissionLevel MaximumAuthorizedPermissionLevel { get; private set; }

        protected UserReport() { }

        public virtual bool IsAuthorizedForAny(Type[] roleTypes)
        {
            foreach (var roleType in roleTypes)
            {
                var role = (IRole)Activator.CreateInstance(roleType);
                if (MaximumAuthorizedPermissionLevel.IsAuthorizedFor(role.PermissionLevel))
                    return true;
            }

            return false;
        }
    }
}
